Refactor Assign Entities workflow and update related documentation - #174
Conversation
- Added detailed architecture documentation for the Assign Entities process, outlining the flow from user input to async processing and GitHub commit. - Updated existing documentation to reference the new Assign Entities architecture. - Modified the entities preview template to ensure consistent display of entity organisation CSV and old entity summary. - Enhanced acceptance tests to validate the correct handling of selected entities and redirects in the Assign Entities flow. - Adjusted unit tests to reflect changes in the handling of entity redirects, ensuring they are not passed to the GitHub workflow. - Improved logic in the duplicate candidate preparation to correctly manage auto-selection and locking of redirects based on entity selection.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (4)
WalkthroughThe Assign Entities flow now supports selecting entities and redirects across paginated results, validating and resubmitting changed selections asynchronously, deriving preview data from ChangesAssign Entities workflow
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CheckTransformUI
participant flagged_resource_detail_post
participant pipeline-summary
participant AsyncRequest
User->>CheckTransformUI: select/deselect entities and redirects
CheckTransformUI->>flagged_resource_detail_post: submit selection state
flagged_resource_detail_post->>pipeline-summary: fetch current candidates
pipeline-summary-->>flagged_resource_detail_post: return entity and redirect rows
flagged_resource_detail_post->>AsyncRequest: submit validated excluded/selected
AsyncRequest-->>CheckTransformUI: return replacement request id
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
application/templates/datamanager/entities_preview.html (1)
205-214: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer GovUK utility classes over inline styles.
To align with GovUK styling conventions, consider replacing the inline styles with the appropriate utility classes, such as
govuk-!-padding-3,govuk-!-margin-bottom-5, and a background colour class (or wrapping the content in a standard component like an inset text or panel).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@application/templates/datamanager/entities_preview.html` around lines 205 - 214, Replace the inline styling on the redirect-count container around the “Number of redirects” summary row with GOV.UK utility classes, using the appropriate padding, margin-bottom, and background-colour/component classes while preserving the existing layout and content.application/blueprints/datamanager/controllers/preview.py (1)
121-137: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valuePrevent rendering
"None"for null JSON values.If the async API returns
nullfor any of these fields (e.g.,{"status": null}),old_entity.get("status", "")will evaluate toNone, whichstr()will convert to the string"None".Consider appending
or ""(and removing the fallback fromget()) to ensureNonevalues are coerced to empty strings before string conversion.♻️ Proposed fix
row = { "old-entity": str( - old_entity.get("old-entity", "") or old_entity.get("old_entity", "") + old_entity.get("old-entity") or old_entity.get("old_entity") or "" ), - "status": str(old_entity.get("status", "")), - "entity": str(old_entity.get("entity", "")), - "notes": str(old_entity.get("notes", "")), + "status": str(old_entity.get("status") or ""), + "entity": str(old_entity.get("entity") or ""), + "notes": str(old_entity.get("notes") or ""), "end-date": str( - old_entity.get("end-date", "") or old_entity.get("end_date", "") + old_entity.get("end-date") or old_entity.get("end_date") or "" ), "entry-date": str( - old_entity.get("entry-date", "") or old_entity.get("entry_date", "") + old_entity.get("entry-date") or old_entity.get("entry_date") or "" ), "start-date": str( - old_entity.get("start-date", "") or old_entity.get("start_date", "") + old_entity.get("start-date") or old_entity.get("start_date") or "" ), }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@application/blueprints/datamanager/controllers/preview.py` around lines 121 - 137, Update the row construction in the preview controller so every old_entity field uses an empty-string fallback before str() conversion, including status, entity, and notes, while preserving the existing hyphenated/underscored key fallback behavior for old-entity and date fields. This must render null JSON values as empty strings rather than "None".
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@application/blueprints/datamanager/controllers/transform.py`:
- Around line 250-254: The existing-row deduplication in _build_entities_data is
ineffective because organisation is removed before
_entity_candidate_reference_key is evaluated. Preserve organisation/reference
data when deriving existing_reference_keys, and ensure candidates with matching
organisation/reference are skipped even when their entity value differs or is
blank, while retaining same-loop deduplication.
---
Nitpick comments:
In `@application/blueprints/datamanager/controllers/preview.py`:
- Around line 121-137: Update the row construction in the preview controller so
every old_entity field uses an empty-string fallback before str() conversion,
including status, entity, and notes, while preserving the existing
hyphenated/underscored key fallback behavior for old-entity and date fields.
This must render null JSON values as empty strings rather than "None".
In `@application/templates/datamanager/entities_preview.html`:
- Around line 205-214: Replace the inline styling on the redirect-count
container around the “Number of redirects” summary row with GOV.UK utility
classes, using the appropriate padding, margin-bottom, and
background-colour/component classes while preserving the existing layout and
content.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1a0bc287-138b-48e6-817d-3a918fd10648
📒 Files selected for processing (15)
application/blueprints/datamanager/controllers/flagged_resources.pyapplication/blueprints/datamanager/controllers/preview.pyapplication/blueprints/datamanager/controllers/transform.pyapplication/blueprints/datamanager/router.pyapplication/blueprints/datamanager/services/github.pyapplication/templates/components/check-transform-base.htmlapplication/templates/datamanager/assign-entities-check-results.htmlapplication/templates/datamanager/entities_preview.htmldocs/assign-entities/architecture.mddocs/datamanager/architecture.mddocs/datamanager/github-add.mdtests/acceptance/blueprints/datamanager/test_flagged_resources.pytests/unit/blueprints/datamanager/controllers/test_add.pytests/unit/blueprints/datamanager/controllers/test_transform.pytests/unit/blueprints/datamanager/services/test_github.py
💤 Files with no reviewable changes (1)
- application/blueprints/datamanager/services/github.py
…umentation for clarity
|
Tip For best results, initiate chat on the files or code changes.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
…selected entities and update related templates and tests
pooleycodes
left a comment
There was a problem hiding this comment.
Looks good, maybe just need to remove the RequestMeta.entity_redirects db column and writing to it as i don't think needed anymore?
…ate architecture documentation, and adjust tests accordingly
What type of PR is this? (check all applicable)
Description
Adds selection support to the Assign Entities flow so users can choose which new entity references should be processed before continuing to preview.
This updates the Assign Entities results page to support entity checkboxes, Dedup selection changes, replacement async requests using
selected_entitiesandselected_redirects, and preview rendering from async-generatednew-entitiesandold-entityoutput. It also removes the old GitHubentity_redirectsdispatch path, since redirects now come from the completed async response.Documentation has been added for the Assign Entities architecture, gotchas, and debugging steps.
Related Tickets & Documents
docs/assign-entities/architecture.mdQA Instructions, Screenshots, Recordings
Test the Assign Entities journey:
pipeline-summary.new-entitiespipeline-summary.old-entityentity_redirects.Added/updated tests?
Focused validation run:
[optional] Are there any post deployment tasks we need to perform?
No.
[optional] Are there any dependencies on other PRs or Work?
Depends on async support for
selected_entities,selected_redirects,pipeline-summary.all-entities, andpipeline-summary.old-entity.Summary by CodeRabbit